package com.xuliugen.lsm.resource.load;

import java.io.IOException;
import java.io.InputStream;
import java.lang.reflect.Field;
import java.util.HashMap;
import java.util.Map;
import java.util.Properties;

public class ResourceLoad {

    private static Map<String, String> content;

    static {
        InputStream in = Thread.currentThread().getContextClassLoader().getResourceAsStream("lsm.properties");
        Properties pop = new Properties();
        try {
            pop.load(in);
            content = new HashMap<String, String>();
            Field[] fields = Content.class.getDeclaredFields();
            for (Field field : fields) {
                String key = field.getName();
                content.put(key, pop.getProperty(key));
            }
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            try {
                assert in != null;
                in.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }

    public static Map<String, String> getContent() {
        return content;
    }

    @SuppressWarnings("unused")
    public static void main(String[] args) {
        ResourceLoad load = new ResourceLoad();
    }
}
